package com.zareal.exception;

import com.zareal.enums.GlobalErrorCode;

/**
 * @BelongsProject: itsource-ymcc
 * @BelongsPackage: cn.itsource.exception
 * @Author: Director
 * @CreateTime: 2022-08-07  15:40
 * @Description: 全局自定义异常
 * @Version: 1.0
 */
public class GlobalCustomException extends RuntimeException{

    // 异常信息
    private String errorMessage;

    // 异常码
    private String errorCode;

    public GlobalCustomException(){
        super();
    }

    public GlobalCustomException(String errorCode, String errorMessage){
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public GlobalCustomException(GlobalErrorCode globalErrorCode){
        super(globalErrorCode.getErrorMessage());
        this.errorCode = globalErrorCode.getErrorCode();
        this.errorMessage = globalErrorCode.getErrorMessage();
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
}